// 导入接口函数
import request from '../utils/request'

// 封装方法,文章详情接口
const getArticleDetailAPI = ({ artId }) => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${artId}`
  })
}

// 封装方法关注作者接口
const followAutAPI = ({ artId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: artId
    }
  })
}

// 封装方法取消关注作者接口
const unfollowAutAPI = ({ artId }) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${artId}`
  })
}

// 封装方法  喜欢文章
const likeArtAPI = ({ artId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: artId
    }
  })
}

// 封装方法  不喜欢文章
const dislikeArtAPI = ({ artId }) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${artId}`
  })
}

// 封装 获取评论列表
const getArtCommentAPI = ({ artId, offset, limit }) => {
  return request({
    method: 'GET',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset,
      limit
    }
  })
}

// 封装方法  喜欢的评论
const likecommentAPI = ({ cmtId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target: cmtId
    }
  })
}

// 封装方法  不喜欢的评论
const dislikecommentAPI = ({ cmtId }) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/comment/likings/${cmtId}`
  })
}

// 封装方法   发布评论
const publishcmtAPI = ({ artId, data }) => {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data: {
      target: artId,
      content: data
    }
  })
}

// 导出
export {
  getArticleDetailAPI,
  followAutAPI,
  unfollowAutAPI,
  likeArtAPI,
  dislikeArtAPI,
  getArtCommentAPI,
  likecommentAPI,
  dislikecommentAPI,
  publishcmtAPI
}
